<template>
  <div class="login-container flx-center">
    <div class="login-box">
      <SwitchDark class="dark" />
      <div class="login-left">
        <img class="login-left-img" src="@/assets/images/login_left.png" alt="login" />
      </div>
      <div class="login-form">
        <div class="login-logo">
          <img class="login-icon" src="@/assets/images/logo.svg" alt="" />
          <h2 class="logo-text">{{ title }}</h2>
        </div>
        <OtherLogin @wechatHandleClick="wechatHandleClick" @tencentHandleClick="tencentHandleClick" />
        <LoginForm />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts" name="login">
import LoginForm from "./components/LoginForm.vue";
import OtherLogin from "./components/OtherLogin.vue";
import SwitchDark from "@/components/SwitchDark/index.vue";
const title = import.meta.env.VITE_GLOB_APP_TITLE;
import openWindow from "@/utils/open-window.js";
// 微信登录
const wechatHandleClick = thirdpart => {
  // alert('ok')
  const appid = "xxxxx";
  const redirect_uri = encodeURIComponent("xxx/redirect?redirect=" + window.location.origin + "/auth-redirect");
  const url =
    "https://open.weixin.qq.com/connect/qrconnect?appid=" +
    appid +
    "&redirect_uri=" +
    redirect_uri +
    "&response_type=code&scope=snsapi_login#wechat_redirect";
  openWindow(url, thirdpart, 540, 540);
};
// QQ登录
const tencentHandleClick = thirdpart => {
  // alert('ok')
  const client_id = "xxxxx";
  const redirect_uri = encodeURIComponent("xxx/redirect?redirect=" + window.location.origin + "/auth-redirect");
  const url =
    "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=" + client_id + "&redirect_uri=" + redirect_uri;
  openWindow(url, thirdpart, 540, 540);
};
</script>

<style scoped lang="scss">
@import "./index.scss";
</style>
